<template>
	<view>
		
		<view class="select-view" style="border: #318df1 solid 4rpx;" @click="scan">
			<text>{{title}}</text>
			<image src="/static/scan.png" mode="aspectFit"></image>
		</view>
		<!-- 
		<view class="select-view" style="border: #fe9a03 solid 4rpx;" @click="input">
			<text>录入出库</text>
			<image src="/static/input.png" mode="aspectFit"></image>
		</view>
		 -->
	</view>
</template>
<style lang="scss">
	page{
		background-color: #FFFFFF;
	}
	.select-view{
		display: flex;
		flex-direction: row;
		background-color: #FFFFFF;
		justify-content: space-between;
		align-items: center;
		height: 352rpx;
		width: 700rpx;
		margin: 0 auto;
		margin-top: 70rpx;
		box-sizing: border-box;
		padding: 100rpx;
		border-radius: 20rpx;
		text{
			font-size: 34rpx;
			font-weight: bold;
		}
		image{
			width: 100rpx;
			height: 100rpx;
		}
	}
</style>
<script>
	export default {
		data() {
			return {
				type:0,
				title:'',
			}
		},
		onLoad(options){
			this.type = options.type;
			this.title= this.type == 1 ? '扫码认证' : '扫码认证'
			uni.setNavigationBarTitle({
				title:this.type == 1 ? '商品认证' : '货品验证'
			});
		},
		methods: {
			scan(){
				uni.scanCode({
					onlyFromCamera:true,
					scanType:"qrCode",
					success:res => {
						if(res.errMsg == "scanCode:ok" && res.result){
							// this.$u.http.get("mall/goods/get",{sn:res.result,type:'user'}).then(res => {
							// 	if(res.code==1){
							// 		uni.navigateTo({
							// 			url:"/pages/mall/info?id="+res.data
							// 		})
							// 	}else{
							// 		this.$u.toast(res.msg);
							// 	}
							// })
							uni.request({
										method:"get" ,//请求方式默认是get
										url:res.result,
									
										success: (res) => {
										console.log("111",res);
											if(res.data.code){
													uni.navigateTo({
														url:"/pages/mall/info?id="+res.data.data
													})
												}else{
													this.$u.toast(res.data.msg);
												}
										}
									})
						}else{
							this.$u.toast("扫码失败");
						}
					},
					fail(){
						this.$u.toast("扫码失败");
					},
					complete(res){
						console.log(res);
					}
				})
			},
			input(){
				uni.navigateTo({
					url:"/pages/mall/next"
				})
			}
		}
	}
</script>

<style>

</style>
